/*
 * Antonio Canabrava Fraideinberze 7152292
 * Lucas Avelino Sodre Santos      7239086
 * Pedro Rael Garcia               7153021
 */

/*
 * Library used in programs that implements avl tree
 */
#ifndef AVL_H_INCLUDED
#define AVL_H_INCLUDED

/*
 * Source with adaptations for specific use
 * http://www.zentut.com/c-tutorial/c-avl-tree/
 */

#include "row.h"

/* structure of the node of avl tree*/
typedef struct node
{
    char *word;
    struct node *left;
    struct node *right;
    int blocks;
    int complete;
    int size_word;
    int *partition;
    row rowSub;
    int height;
} node;

/* clear the whole tree until node t */
void clear(node *t);

/* find a specific node's key in the tree */
node *find(char *word, node *t);

/* find a specific node's key in the tree */
node *findSub(char *word, node *t, int i);

/* find a specific node's key in the tree */
node *findN(char *word, node *t, int len);

/* find minimum node's key */
node *find_min(node *t);

/* find a maximum node's key */
node *find_max(node *t);

/* get the height of a node */
node *insert(char *word, node *t);

/* get the height of a node */
node *insertSub(char *word,char* wordComplete, node *t,int i);

/* data of a node */
char *get(node *n);

/* recursively display avl tree */
void display_avl(node* t);

/*  display row */
void display_avl_row(node* t);

/*  get a element of the row */
char* getRowNode(node* t);

void display_avl_blocks(node *t);

void display_avl_left(node *t);

int getSizeTree(node *t);

#endif /* AVL_H_INCLUDED */
